package com.twu.biblioteca;

public class Book implements Item {
    private String title;
    private String author;
    private int year;
    private boolean checkedOut;

    public Book(String title, String author, int year) {
        this.title = title;
        this.author = author;
        this.year = year;
    }

    @Override
    public String displayTitle() {
        return title;
    }

    @Override
    public String displayDetails() {
        return String.format("%s | %s | %d", title, author, year);
    }

    @Override
    public boolean checkout() {
        if(checkedOut) {
            return false;
        }
        checkedOut = true;
        return true;
    }

    @Override
    public boolean returnItem() {
        if(!checkedOut) {
            return false;
        }
        checkedOut = false;
        return true;
    }

    @Override
    public boolean isCheckedOut() {
        return checkedOut;
    }
}